package com.batchengine.task;

import com.batchengine.Definitions;

/**
 * Created by  solutions
 * Author: sunil.incubator@yahoo.com
 * Date: Aug 9, 2009
 */
public class RecurringJob {

    private Long jobId;
    private Integer delay;
    int minWorkers;
    int maxWorkers;
    private String instanceName;

    private TaskInfo taskInfo;
    private Definitions.DelayParam delayParam;

    public RecurringJob(Long jobId) {
        this.jobId = jobId;
    }

    public Long getJobId() {
        return jobId;
    }

    protected void setId(Long jobId) {
        this.jobId = jobId;
    }

    public String getInstanceName() {
        return instanceName;
    }

    public void setInstanceName(String instanceName) {
        this.instanceName = instanceName;
    }

    public int getMinWorkers() {
        return minWorkers;
    }

    public void setMinWorkers(int minWorkers) {
        this.minWorkers = minWorkers;
    }

    public int getMaxWorkers() {
        return maxWorkers;
    }

    public void setMaxWorkers(int maxWorkers) {
        this.maxWorkers = maxWorkers;
    }

    public Integer getDelay() {
        return delay;
    }

    protected void setDelay(Integer delay) {
        this.delay = delay;
    }

    public Definitions.DelayParam getDelayParam() {
        if (null != delayParam) {
            return Definitions.DelayParam.SEC;
        }
        return delayParam;
    }

    protected void setDelayParam(Definitions.DelayParam delayParam) {
        this.delayParam = delayParam;
    }

    public TaskInfo getTaskInfo() {
        return taskInfo;
    }

    public void setTaskInfo(TaskInfo taskInfo) {
        this.taskInfo = taskInfo;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("RecurringJob");
        sb.append("{jobId=").append(jobId);
        sb.append(", instanceName=").append(instanceName);
        sb.append(", delay=").append(delay);
        sb.append(", minWorkers=").append(minWorkers);
        sb.append(", maxWorkers=").append(maxWorkers);
        sb.append(", taskInfo=").append(taskInfo);
        sb.append(", delayParam=").append(delayParam);
        sb.append('}');
        sb.append("\n");
        return sb.toString();
    }
}
